<template>
  <div class="editor-overview-pad" ref="paletteRef" v-show="overviewPadVisible">
    <div class="editor-overview-pad__title">图层管理</div>
    <div
      v-for="(cp, index) in componentList"
      :class="{
        'editor-overview-pad__item': true,
        'is-active': acId === cp.id,
      }"
      :key="cp.id"
      @click.stop="setActiveComponent(cp, index)"
    >
      <span class="editor-overview-pad__item-name">{{
        `${cp.name} - ${cp.id}`
      }}</span>
      <span v-show="cp.isLocked" class="editor-overview-pad__item-lock">
        <i class="el-icon-lock"></i>
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'OverviewPad',
  data(){
    return{

    }
  },
  computed: {
    overviewPadVisible(){
      return this.$store.state.imageDragMoudules.editorConfig.overviewPadVisible;
    },
    componentList(){
      return this.$store.state.imageDragMoudules.components;
    },
    acId(){
      const acComponent = this.$store.state.imageDragMoudules.acComponent;
      let acId = ''
      if(acComponent != null){
        acId = acComponent.id;
      }
      return acId;
    }
  },
  methods:{
    setActiveComponent(component,index){
      this.$store.commit('setActivated', { type: 'component', component, index });
    }
  }
}
</script>

<style lang="scss" scoped>
.editor-overview-pad {
  position: fixed;
  top: 140px;
  right: 235px;
  z-index: 100;
  width: 240px;
  min-height: 320px;
  max-height: 60vh;
  overflow-y: auto;
  background: #1b1b20;
  color: #b6b8cc;
  &::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
  .editor-overview-pad__title {
    font-size: 14px;
    text-align: center;
    line-height: 32px;
    height: 36px;
    background: #20202a;
    margin-bottom: 8px;
    position: sticky;
    top: 0;
  }
  .editor-overview-pad__item {
    display: flex;
    font-size: 12px;
    line-height: 24px;
    height: 24px;
    box-sizing: border-box;
    padding: 0 8px;
    gap: 8px;
    justify-content: space-between;
    &:hover {
      cursor: pointer;
      background: #20202a;
    }
    &.is-active {
      background: linear-gradient(143deg, #335ae9, #6f6ff5);
      color: #ffffff;
    }
  }
  .editor-overview-pad__item-lock {
  }
}
</style>
